package com.health.controller;

import com.health.vo.Result;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class LoginController {

    @RequestMapping("/loginSuccess")
    public Result loginSuccess(){
        //获取当前登录的用户名
        String username = SecurityContextHolder.getContext().getAuthentication().getName();

        return new Result(true,"登录成功",username);
    }

    @RequestMapping("/loginFail")
    public Result loginFail(){
        return new Result(false,"登录失败");
    }
}
